From cb1325b0d5f2809eeb855ef3dc655366536910b8 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Fri, 3 Dec 2010 09:36:47 +0000 Subject: [PATCH] libxc: osdep: convert xc_evtchn_bind_unbound_port() Signed-off-by: Ian Campbell Signed-off-by: Ian Jackson --- tools/libxc/xc_evtchn.c | 6 ++++++ tools/libxc/xc_linux.c | 8 +++++--- tools/libxc/xc_minios.c | 12 +++++++----- tools/libxc/xc_netbsd.c | 8 +++++--- tools/libxc/xc_solaris.c | 8 +++++--- tools/libxc/xenctrlosdep.h | 2 ++ 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/tools/libxc/xc_evtchn.c b/tools/libxc/xc_evtchn.c index ff807e8b5a..047b519331 100644 --- a/tools/libxc/xc_evtchn.c +++ b/tools/libxc/xc_evtchn.c @@ -88,6 +88,12 @@ int xc_evtchn_notify(xc_evtchn *xce, evtchn_port_t port) return xce->ops->u.evtchn.notify(xce, xce->ops_handle, port); } +evtchn_port_or_error_t +xc_evtchn_bind_unbound_port(xc_evtchn *xce, int domid) +{ + return xce->ops->u.evtchn.bind_unbound_port(xce, xce->ops_handle, domid); +} + /* * Local variables: * mode: C diff --git a/tools/libxc/xc_linux.c b/tools/libxc/xc_linux.c index 4ad545a07d..0ae64fa26c 100644 --- a/tools/libxc/xc_linux.c +++ b/tools/libxc/xc_linux.c @@ -375,14 +375,15 @@ static int linux_evtchn_notify(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t return ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); } -evtchn_port_or_error_t -xc_evtchn_bind_unbound_port(xc_evtchn *xce, int domid) +static evtchn_port_or_error_t +linux_evtchn_bind_unbound_port(xc_evtchn *xce, xc_osdep_handle h, int domid) { + int fd = (int)h; struct ioctl_evtchn_bind_unbound_port bind; bind.remote_domain = domid; - return ioctl(xce->fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); + return ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); } evtchn_port_or_error_t @@ -439,6 +440,7 @@ static struct xc_osdep_ops linux_evtchn_ops = { .u.evtchn = { .fd = &linux_evtchn_fd, .notify = &linux_evtchn_notify, + .bind_unbound_port = &linux_evtchn_bind_unbound_port, }, }; diff --git a/tools/libxc/xc_minios.c b/tools/libxc/xc_minios.c index 30c2f3b529..0a04e4517b 100644 --- a/tools/libxc/xc_minios.c +++ b/tools/libxc/xc_minios.c @@ -277,26 +277,27 @@ static void evtchn_handler(evtchn_port_t port, struct pt_regs *regs, void *data) wake_up(&event_queue); } -evtchn_port_or_error_t xc_evtchn_bind_unbound_port(xc_evtchn *xce, int domid) +static evtchn_port_or_error_t minios_evtchn_bind_unbound_port(xc_evtchn *xce, xc_osdep_handle h, int domid) { + int fd = (int)h; int ret, i; evtchn_port_t port; assert(get_current() == main_thread); - i = port_alloc(xce->fd); + i = port_alloc(fd); if (i == -1) return -1; printf("xc_evtchn_bind_unbound_port(%d)", domid); - ret = evtchn_alloc_unbound(domid, evtchn_handler, (void*)(intptr_t)xce->fd, &port); + ret = evtchn_alloc_unbound(domid, evtchn_handler, (void*)(intptr_t)fd, &port); printf(" = %d\n", ret); if (ret < 0) { errno = -ret; return -1; } - files[xce->fd].evtchn.ports[i].bound = 1; - files[xce->fd].evtchn.ports[i].port = port; + files[fd].evtchn.ports[i].bound = 1; + files[fd].evtchn.ports[i].port = port; unmask_evtchn(port); return port; } @@ -404,6 +405,7 @@ static struct xc_osdep_ops minios_evtchn_ops = { .u.evtchn = { .fd = &minios_evtchn_fd, .notify = &minios_evtchn_notify, + .bind_unbound_port = &minios_evtchn_bind_unbound_port, }, }; diff --git a/tools/libxc/xc_netbsd.c b/tools/libxc/xc_netbsd.c index 5341a27442..6bd72d970e 100644 --- a/tools/libxc/xc_netbsd.c +++ b/tools/libxc/xc_netbsd.c @@ -225,15 +225,16 @@ static int netbsd_evtchn_notify(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t return ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); } -evtchn_port_or_error_t -xc_evtchn_bind_unbound_port(xc_evtchn * xce, int domid) +static evtchn_port_or_error_t +netbsd_evtchn_bind_unbound_port(xc_evtchn * xce, xc_osdep_handle h, int domid) { + int fd = (int)h; struct ioctl_evtchn_bind_unbound_port bind; int ret; bind.remote_domain = domid; - ret = ioctl(xce->fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); + ret = ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); if (ret == 0) return bind.port; else @@ -304,6 +305,7 @@ static struct xc_osdep_ops netbsd_evtchn_ops = { .u.evtchn = { .fd = &netbsd_evtchn_fd, .notify = &netbsd_evtchn_notify, + .bind_unbound_port = &netbsd_evtchn_bind_unbound_port, }, }; diff --git a/tools/libxc/xc_solaris.c b/tools/libxc/xc_solaris.c index edca1871be..eaacad5f70 100644 --- a/tools/libxc/xc_solaris.c +++ b/tools/libxc/xc_solaris.c @@ -217,14 +217,15 @@ static int solaris_evtchn_notify(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_ return ioctl(fd, IOCTL_EVTCHN_NOTIFY, ¬ify); } -evtchn_port_or_error_t -xc_evtchn_bind_unbound_port(xc_evtchn *xce, int domid) +static evtchn_port_or_error_t +solaris_evtchn_bind_unbound_port(xc_evtchn *xce, xc_osdep_handle h, int domid) { + int fd = (int)h; struct ioctl_evtchn_bind_unbound_port bind; bind.remote_domain = domid; - return ioctl(xce->fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); + return ioctl(fd, IOCTL_EVTCHN_BIND_UNBOUND_PORT, &bind); } evtchn_port_or_error_t @@ -281,6 +282,7 @@ static struct xc_osdep_ops solaris_evtchn_ops = { .u.evtchn = { .fd = &solaris_evtchn_fd, .notify = &solaris_evtchn_notify, + .bind_unbound_port = &solaris_evtchn_bind_unbound_port, }, }; diff --git a/tools/libxc/xenctrlosdep.h b/tools/libxc/xenctrlosdep.h index 6bf2d9ccde..d67d6d40c6 100644 --- a/tools/libxc/xenctrlosdep.h +++ b/tools/libxc/xenctrlosdep.h @@ -78,6 +78,8 @@ struct xc_osdep_ops int (*fd)(xc_evtchn *xce, xc_osdep_handle h); int (*notify)(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t port); + + evtchn_port_or_error_t (*bind_unbound_port)(xc_evtchn *xce, xc_osdep_handle h, int domid); } evtchn; } u; }; -- 2.30.2